import axios from 'axios'
const HOST = import.meta.env.VITE_API_HOST
const PREFIX = import.meta.env.VITE_API_PREFIX
const PROXY_PREFIX = import.meta.env.VITE_API_PROXY_PREFIX
const TIMEOUT = import.meta.env.VITE_TIMEOUT

const http = axios.create({
  baseURL: import.meta.env.DEV
    ? HOST + PREFIX + PROXY_PREFIX
    : HOST,
  timeout: TIMEOUT,
})

http.interceptors.request.use(
  (config) => config,
  (err) => Promise.reject(err),
)

http.interceptors.response.use(
  (res) => res.data,
  (err) => Promise.reject(err),
)

export default http
